added helper functions for mapreduce