use queues instead of pointer magic