revert to Chao's code