Remove some unnecessary code duplication