Better way of checking for indexes