refactored the server a bit