Slight code rearrangement