fix bugs in log printing