add internal error logging