refactoring code(map method)