Refactor State system