refactor validator