add implementation for BFS