correctly retrieving the element index
optimised imports