starting major algorithm refactor
refactor
refactor
refactor
refactor