add logger and make some fixes