indexOf & lastIndexOf issue resolved