minor refactoring, validation