first attempt to implement map/reduce (not functional yet...)