added true cycle decection, making optimizations now