Move document.body.scrollTop outside of loop