fix bug #489 from #429

fix NPE bug #489 from #429