chao's code added