Implemented the isValid and the Path functions