changed apply to map, more flexible