some more refactoring.