Copied fix for issue #6

The fix for issue #6 wasn't already added in this branch