fixed insert-into-list function