refactored validation to where it belongs