refactor loop on exercice 6 week 3