changed some codes that ChenZhenming wrote