Simplified bfs slightly