Fixed small bug in map function