fixed the substring for absent indexB