You don't need to duplicate the loop code. Just iterate while "i < ceil(fabs(deltaY))"