refactoring ping pong