finished server code for users