refactor into validator class