Eliminate some code duplication