refactor handling being offline