wouldn't be better to check first taskID != null ? 

It would shorten code execution in some cases.