minor rearrangement of code to make it look more pretty