Code logic for filtering list items