Refactor code with OOP