Refactor into state.