Refactored errors in to a new class