added some comments and better logging