finished server implementation