add logger.
change mainloop logic.