changed validate function fixed #2