Added error handling for server