fix bug in tasks when switching state