Corrects for temperature variation. Not very general. Working version