added reorder function seq and forloop. Added more comments and reordered header