update database logic