给出以下两个句子，将它们合并成一个更复杂的句子，并保持意思不变。


I went to the store to buy some milk.
I realized I forgot my wallet when I got to the cashier.
I went to the store to buy some milk, but realized I forgot my wallet when I got to the cashier.