Fix substring index