changed algorithm for smooth-scrolling