added a delay to isMoving(), changed parameter type of sleep(..) to int