Refactor validator module