added debug option to stop on every state change