refactored error raising and passing
refactored error raising and passing