implemented Map phase