This paper studies optimal policy for modular product reassembly within a remanufacturing setting where a firm receives product returns with variable quality and reassembles products of multiple classes to customer orders. High-quality modules are allowed to substitute for low-quality modules during reassembly to provide the remanufacturing system with flexibility such that shortage in lower quality modules can be smoothed out by higher quality module inventories. We formulate the problem as a Markov decision process and characterize the structure of the optimal control policy. In particular, we show that the optimal reassembly and substitution follow a state-dependent threshold-based control policy. We also establish the structural properties of the thresholds. Using numerical experimentation, we study how system performance is influenced by key cost parameters including unit holding cost, unit assembly cost and shortage penalty cost. Finally, we compare the optimal policy with an exhaustive reassembly policy and show that there is great benefit in module substitution and threshold-based assembly control.