added some comments
fixed errors