Stealth comment: there may be whitespace other than the space char, so instead of using `lastIndexOf(" ")` I think a regex with `\s` should be used.