code-refactoring and made into objects