finished Compensate() function