add callbacks for bfs