Refactors codes more simply