improved error logging