Refactored code to use a single produce array and implemented directives