Added a check to protect against NPE. "".indexOf is fine.