refactor in update_db local and remote