Checking if index is valid