Fixed NPE
Merge pull request #600 from jidel/npe_fix

Fixed NPE