Only loop through array if params[:q] is present