fix the window.location = bug