Working parallelized version (but has memory leak somehere)