Fix for issue #294

Hi Tom, this is the PR for the patch I had submitted previously.