cleanup and splitting out logic
refactoring