refactoring & merge for internal usage