breadth-first search now fully fuctional