refactor with map fn