bug with error logging