add filter to ignore files and directories instead of passing it to the `toArray` method