Fixed doValidation function