updated with patch from pull request