improved queue management with only one queue and dynamic pointers