refactoring deviation handling
refactoring errorhandling