updateBall to function