Applied some refactoring