implemented correct diff function