Fixed problem with critical region in openMP pragma