Moved node selection algorithm to thread 

fixes #36