improved error-logging