rearranged functions in client/server.