implement efficient queue