A method for controlling temperature of a compressor motor having a motor cooling circuit, the compressor motor in a refrigeration circuit comprising a compressor having a motor, a condenser in fluid communication with the compressor, a first expansion valve in fluid communication with the condenser, an evaporator in fluid communication with the first expansion valve and in fluid communication with the compressor, the motor cooling circuit comprising a second expansion valve in fluid communication with the condenser and the compressor motor, the compressor motor further being in fluid communication with the refrigeration circuit between downstream of the first expansion valve and a compressor inlet, wherein the compressor motor further includes a stator having windings and a rotor mounted within a motor housing and refrigerant fluid provided from the condenser to the motor cooling circuit as a cooling fluid through the second expansion valve, wherein the improvement is characterized by: providing a primary PID loop, the primary PID loop including a compressor motor housing temperature sensor mounted on a motor housing surface, and a first PID controller in communication with the motor housing temperature sensor, the first PID controller further programmed with a motor housing temperature set point; providing a secondary PID loop, the secondary PID loop including a stator winding temperature sensor mounted on the stator windings and a second PID controller in communication with the second expansion valve and the first PID controller, the second PID controller further programmed with a stator winding temperature set point; providing a signal indicative of the stator winding temperature to the second PID controller; providing a signal indicative of the motor housing temperature to the first PID controller; providing a signal from the second PID controller to the second expansion valve regulating refrigerant flow to the motor cooling circuit when the stator winding temperature varies from the stator setpoint temperature; providing a signal from the first PID controller to the second PID controller reprogramming the stator winding temperature setpoint, the stator winding temperature setpoint being dynamically calculated by the first PID controller based on the signal from the motor housing temperature sensor indicative of the motor housing temperature and its variance from the motor housing temperature setpoint as a result of refrigerant flow to the motor cooling circuit. providing a primary PID loop, the primary PID loop including a compressor motor housing temperature sensor mounted on a motor housing surface, and a first PID controller in communication with the motor housing temperature sensor, the first PID controller further programmed with a motor housing temperature set point; providing a secondary PID loop, the secondary PID loop including a stator winding temperature sensor mounted on the stator windings and a second PID controller in communication with the second expansion valve and the first PID controller, the second PID controller further programmed with a stator winding temperature set point; providing a signal indicative of the stator winding temperature to the second PID controller; providing a signal indicative of the motor housing temperature to the first PID controller; providing a signal from the second PID controller to the second expansion valve regulating refrigerant flow to the motor cooling circuit when the stator winding temperature varies from the stator setpoint temperature; providing a signal from the first PID controller to the second PID controller reprogramming the stator winding temperature setpoint, the stator winding temperature setpoint being dynamically calculated by the first PID controller based on the signal from the motor housing temperature sensor indicative of the motor housing temperature and its variance from the motor housing temperature setpoint as a result of refrigerant flow to the motor cooling circuit.