refactored error response code