added to fit the class requirement
implemented breadth-first