Revised map() function