fix error in handling negative diff