refactor  map functions.