add null checks to index constructors