updated the validation function