added ability to auto update the state