adding code from pull request #14