Rearrange processing and change conditions in last row