added an NPE fix for #579