Reducing code duplication