Fixed logic for paths() and walkGraph()