Fix infinite scrolling logic