refactor to remove duplication and extract some methods out of
Mapper.map
fix error logging, did not log stack trace in case of error