refactor: avoided using the confusing local variable name "substr" for string.sub().