added some of the core algorithm for mcReduce