added comments
final program working