Added a function to calculate the results.