Properly setting the error code