added math to calculate temperature