Updates to redirect script to make it work better