Consolidated if statement in update function in ball.js