cleaned up code & added loading check to infinite scroll