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

see comments
Merge remote-tracking branch 'upstream2/master'