handle simple cycle errors + optimizations