need to fix error logging