refactor server.c