added changeState and tests