fmod is faster than while loop