[#2166] Fixed a bug in Tanglin's code