[#46] Fix for NullPointerException

I was abble to reproduce issue #46 and proposed fix solve my case