Fixed bug for temperature calculation