Reworked the looping