Remove some replicated code from the newDist function
Make error output when newdist fails clearer