refactored to make next refactoring easier