added some comments
generate header and total lines