Added online/offline login logic