add some logging and comments