fix bug with counting tasks