finding cycles