tidied up the queue.js code