added logout functionality and a better offline mode