refactored errors module