Move the scrolling logic to a better location