You can use fluid.each here instead of the for loop. Also you are changing the model passed into the function. Are you intending to do this? If not, you may want to use fluid.copy to make a copy of the model first, modify the copy and return that instead.