error fix of diff function