better error handling, especially in mapper