Refactored on error behavior