Updated server.c to use cleanner code