Cycle detection and path printing working