more refactorings to improve throughput