refactor:extract some functions