Fixed bug that occurred ocassionally when the js libraries didnt load in time