autodetect current state added