Move rename logics to separate file