optimize logic for pyPong