array.filter
replaced for loop with array.filter function