Fix code duplication