dual-linked list is slow. don't use it
convert all the NULL to nullptr