add nil context checking
Merge pull request #97 from hlung/hotfix/nil-context

add nil context checking.
Thanks!