fix bugs and log