tennis game, ball stuck in infinite loop

I was working through the tennis game tutorial and got it working except for the part where the ball goes into a infinite bounce between top/bottom walls.
I removed the default collide behaviour for ball and instead add a custom rule which says when ball collides with collidable objects, set direction to
`(self.motion.angularVelocity = -1* self.motion.angularVelocity + random (1, 10)`
hoping that when ball hits the top/bottom walls at 90 or -90 the randomness will change the angle to something other than 90/-90 and ball will break out of the infinite bounce. however it does not work and ball is still stuck in infinite loop. how can I solve this problem ? thanks for your help
I removed the default collide behaviour for ball and instead add a custom rule which says when ball collides with collidable objects, set direction to
`(self.motion.angularVelocity = -1* self.motion.angularVelocity + random (1, 10)`
hoping that when ball hits the top/bottom walls at 90 or -90 the randomness will change the angle to something other than 90/-90 and ball will break out of the infinite bounce. however it does not work and ball is still stuck in infinite loop. how can I solve this problem ? thanks for your help