set head and tail.