fix the function of addState