refactored validator