removed sort function and change iteration count