more refactoring and more to come