use "lastIndexOf" instead of "indexOf"