path search using bfs