properly replace dogeument and windoge