Fully implemented the ping pong mechanism