Moving where clause into separate components for readability and to avoid nesting