variable loop length