Partially working diff function