Added a timer to state change, to prevent disco effect