Make use of the index() method

... instead of the own written function.