more refactoring... WIP