Adding a filtering function