Reviewed function to evaluate mapping gradient