(WIP) refactor to use new algo