Change replaces to for loop