fix a bug causes npe.
Merge pull request #11 from magefree/master

update
Merge pull request #249 from Noahsark/master

fix a bug causes npe.