fixed bug with powering on/off (when wrong state before).