refactored out some code into a package