moving update_inventory function into proper place