Moved update cnchi code to a new function