added offline handling