(textbook example)
A: Honey, which one is for John's birthday? there are two gifts here on the table.
B: Both of them are for John.
A: Then why didn't you put them in one box together?
B: What happened was that I hadn't remembered buying his gift last week and bought another one this afternoon.
(my sentence)
I didn't remember having bought his gift last week and bought another one this afternoon.
the first sentence is what was on my textbook, and the second one is what I made.
first one is where the verb "remember" is written in past tense, and second one is where the verb "buy" is in past tense, so I wondered if the second one I made mean the same thing as the first one.
Do they both mean the same and grammatically correct?
And there's no difference in terms of meaning?