updating while loop logic in the akd tree to attempt to subvert race conditions