refactoring of lengthChange