Make updateScroll() general function