Updating Persistence problem to use a for loop instead of foreach