refactored raising error