rearrange processing function