break main algorithm out into own package