python code edits for map and reduce