in order to improve readability, we can move most for-loops outside the functions e.g. this will also greatly simplify our writing of unittests