fix some bug while writting the log