add null check
Merge pull request #37 from anilsaldhana/master

see comments