better handle of error
Merge pull request #1 from fraserxu/better-err

better handle of error