rework from a clean base

reworked from a clean base and updated error message
Merge pull request #57 from xdchen/bug911169-rework

Rework on Bug 911169 from a clean base - nice work!