fixed bug causing cycles in path