fix bugs in logging