cannot read property of undefined fixed

fields seems to be undefined sometimes.
Merge pull request #39 from JohnnyBill/patch-1

cannot read property of undefined fixed