Updated error logging