How to best write queues and stack