code rearranged