Added new insert_device_code function