"reordered code and added some comments"