modified mem_queue