implement finding cycles in arrays