handled toggle between offline and online