Update Factor_functions.r