finished the first draft of server side code