added some commens and fixed some issue