A butt load of changes
switch to a recursive solution