This paper presents a new method for the design of distributed controllers that achieves component swapping modularity (CSM) in control systems. Our approach, referred to as the direct method, is based on solving a bilevel optimization problem to obtain the distributed controller gains directly. In the previously proposed three-step method, the distributed controllers were obtained by matching with a precomputed centralized controller. To illustrate our approach, we consider an engine idle speed control problem, where CSM is achieved with respect to the throttle actuator. The results indicate that the direct method can significantly improve the CSM metric compared to the three-step method. In addition, for a certain distributed control structure, the direct method enables the designer to tradeoff between desired system performance and CSM.