simpler difference function