fixed critical bug in validate() function (missing return value leading to unpredictable results)