rename state to last_id