correct use of substring