manually appying original pull request #207