remove head and tail