Function chops off ends of list