This should take character indices, not word indices (which was where the error was coming from)