Fixed validate fuction