server refactored, client works