added some more comments in code