Redirect Loop

I have the following code in my controller:

  def list_by_so_number     if request.get?       @histories = History.find(:all, :conditions => ['so_number = ?', params[:sales_order_number]], :order => 'timestamp desc')       if @histories.length < 1 then           flash[:notice] = 'There isn\'t a Sales Order that matches the number you entered'           redirect_to :action => 'list_by_so_number'         end   end   end

My problem is that when I purposely enter a bogus so_number, I wind up in a redirect loop, because of the redirect_to :action => 'list_by_so_number' line.

How can I rewrite this so that when no histories are found, it'll redirect to the list_by_so_number action, and notify the user?

Thanks,