added online/ofline detection