fixed addState method to properly setup the state