validation utils + refactoring