The two branches contain some duplication:

```ruby
if ...
  ...
  contacts = people
else
  ...
  contacts = contact.contacts
end

count = contacts.count
contacts = contacts.limit(8)
...