Made code more modular.