small code rearrangements