implementing scrolling logic