Better queue implementation