Updated cycle to support recursion