added online/offline handling