Fixed validation logic