Combined the visited list and queue to one list