refactor substrings