According to 'Grammar Girl,' doubled words are proper English.
Acceptable Doubled Words
Sometimes in the normal course of writing or speaking, we have to double words because that’s just how the sentence comes out.
We might say something like, “When I gave her her hat back, she thanked me.” Word does not approve, but the sentence is grammatical, if a bit awkward.
Another example is “By the time I thought of it, it was too late.” In this case, you can put a comma between the “it”s to make the sentence easier to follow.
Although these doubled words are correct, consider rewording your sentence if the repeated words bother you.
https://www.quickanddirtytips.com/education/grammar/when-are-double-words-ok