Fixed parallel code, but not yet tested