Modified implementation for adjlist