more refactoring to classes