Added looping logic