extracted a part of map method