fix auto redirect better code, works on all devices.