adding Rafal's change from pull 23