loop function returns whether looping occured