reduce duplicated codes