use threaded queue to simplify and make faster