updating dist with unneeded toArray() calls removed