replaced ugly broken bouncing code with beautiful working code