Fixing filtering on an array