small code rearrangement