improve code with array.filter