fix NPE

resolves #567