(bug fix)- loading gif closes before the page is rendered