added next and prev pointers and extracted constants