additional logic to prevent redirect loops