Convert substring check into string-at-position check for speed