Code now works in parallel!
Fixed bug