add the function online and  offline