rebuilt server and pseudocoded the main game loop