Better fix for issue #89

This should fix issue #89. Improved it per yellis's recommendations in the previous pull request.