some code for server implementation