changed first/last to head/tail