Ensure variable indexes are valid