DRYed out a line and fixed if/else logic