improved infinite scrolling logic