refactoring to prepare for real-time export