Revert part of 488fa81003e5eeb88fbeaff6e6e5224862bedec6

- erroneous merging of substr (val is not defined in the second substr)

Fails at least in latest Chrome.