Corrected module loop logic.