fixed rel_diff function