updated functions code