Adding error handling to the service