First refactoring to classes