fixing npe and incorrect formatting
Merge pull request #66 from novikam/master

fixing npe and incorrect formatting