Refactored validator