extrated the filtering in a common method