nanotube algorithm thingy