fixed insertion to take into account the case a list is empty