improved redirect script with new methods