fix bugs + parallelize