mainly bfs host side code