Change the code for arrays as queues