Calculating final temperature