fix emit-loops