refactored to use setStateWrapper methodd