Added a check for only document loads