added recursion in adding cycles