fix map function, almost all done