please refactor the while block "if (config.filtered())" into its own method to increase readability