I still think the double replacement is completely insane, but that doesn't need to be addressed in this PR