use map in place of for