beginning of bfs implementation