Check if index exists first