Fix the modulus check on the loop iteration.