Added extra error logging