fix NPE
Merge pull request #640 from davherrmann/issue#567

fix NPE