Utilized indexOf() instead of slice()