added some comments and cosmetic