fixed the scrolling js and DRYed up some of the code