adding check if array with distances to model is empty

In function "computeModel" after getting distances to the model (line 101) there is no check if array is empty. As result, the following for-loop (line 114) crashes because it tries to read values from empty array.