reorganize inside-r