Added two checks for empty data sets which would result in bounds check exceptions