Moving filter logic to a separate method