snippets of MapReduce functions