Added functionality to specify which index to use