cleaned up server code slightly