corrected map function