Created class to implement bfs