refactored validation