optimized pong code