code cleanup/rearrangement