multithreaded reduce and code formatting