chaining map reduce with helper variable