modified particle filter for loop