Implemented validation and enforced error handling