Fix bug reported in Issue #222. Thanks jefff888