sort of works, but going to change the algorithim to go the other way after this commit