Finished cycleDetect functions with passing tests