Refactor next_id of sentence