Use slice instead of indexOf for startsWith & endsWith