fixed logging of errors