Implemented breadth first search