pong: code refactoring