replace state with state0 for clarity