Some changes to make more flexible

fixed redirectresult loop