Little modification : lastIndexOf is better than indexOf...