add some comments explaining the calculations