updated looping answer