make db update safe to run multiple times