added server functionality to the game main loop