Add logic to handle IndexOutOfBound and NullDataset Exceptions