cleanup: use String#[] instead of "captures.first rescue nil"