Improve redirect script