[refactor] Put common functions into another file