more refactoring to repackage stuff