Add null reference check in IndexBuilder