add state changed listener