Better error handling in mapping