sample code rearranged