fix bugs, and add logger