Made code more modular