What issues might be causing the loop function not to run the provided function correctly