writing isVisit func