Please improve the style of the whole function.