Fix script execution on page change