fix the loop from step5 to step10