BFS is more preferable for this task (optinal fix)