fixing difference calculation