change code to more oop