Refactoring code and modularizing code