cleaned up the path solving code some more