re-organised code for sepration of concerns, reduced code size
Moved abstracted queue to separate file