add saveIfOffline function