improved code for image db update.