Making a state manager