factoring out more server functions to use in client and finishing working client