refactor: extract some function