Improve login checking