fixed bug that happens when trying to load before page is finished