I'm not sure why your code is so complicated.
Code:
arg1 = string.gsub(arg1, "%s+", " ") -- Replaces consecutive spaces with one space
part1, part2 = string.split(" ", arg1) -- splits arg1 by the delimiter " " character
part1 = string.lower(part1)
part2 = string.lower(part2)
Note that string.split() returns as many results as there are strings delimited by the delimiter.