catch errors in map function