move state into state object