manage state with an object