fixed external domain access issue, substing on undefined issues