Loop removed and state saved, logs added