refactored create/update failure to improve code quality