Corrected queue implementation