refactor in reducing redundant func.