Moved state-loop higher.