I'm not sure when to use the past perfect tense.
I saw this sentence online: He awoke thinking he was in a prison and that he'd been arrested for robbery. He then realized that it had all been a bad dream.
I kind of understand the first instance of past perfect (...he'd been arrested for...