trying prioiryqueue
working version (incorrectly)
working (but slow) version