Added function to compute the differences