parallelized somewhat...but it works.