even more refactoring and more to come