refactored/reduced in preparation for merge