improve error handling with logs in case of exceptions