move mod within for loop