Added mapreduce functions