Your sentence is correct. The past perfect is normally used in the subordinate clause when the subordinate clause refers to an earlier time than the main clause.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.