Refactored the server