moved some search logic from view to layout