cleand up the queue and encapsulated it in a queue structure with head, tail and total properties