To restructure code to make it easier to understand and to maintain, while preserving its functionality.