update db only if required