add new version for nested loops
intermediate state