Simple mapreduce algorithm implementation with additional rereduce step