Change repetitive to loop method