Moving list update code into its own function