unrefactor copyStates, a small function used only once