loopstate explanation added