refactoring to use classes