Add error handling and update server loop to parse request/return response