fixing traversal for breadth first, pointers that are accidentally changed twice