refactoring(use of map function)