issue is a problem with threading. removing the openmp pragma fixed it, but now everything is slow as balls