integrate changes from pull request #5, fixes #5