merge yanghua's code