Added error checking to validate() method