Remove some code dupe. Reformat code