state switching on callback