add visited list functionality