Adding my own take on Scott Beamer's direction optimizing BFS