Teng's code