nit here and also the else could read better with tail vs head.prev.