fix NPE handling for substring?