Updating formatting and reorganizing logic