changed to queue data structure