the conditional variable worked to fix this bug you can see the answer in this post, maybe a better fix will come with time