Stop site loading unecessary pages

adds if statement to check whether there is no more content to load and
then doesn't load any more