Reduced code duplication significantly