Made loginExpired() method more resilient