Revised error logging