fix NPE if task is null