refactored out some common code