bfs code : next will be dynamic switching impplementation