added ball collision detection