fix when document loads glitch