Implemented function initialIteration() and fixed the record iteration order to be correct