Added functionality to correctly calculate the answer.