Simplify the code in taskGetNzCount()