refactoring method

Fixed up a method with lots of repeating code. Was just laziness, now
cleaner to read.