remove some unnecessary code duplication