adding Rafal's change from pull request 23