modified version of trying to improve throughput