update with gradient