fix validate function