rearrange the reprojection code