Refactored to include additional custom class for exceptions.