linked-list removal and error handling complete