fixed the race condition where login sometimes did not get flagged.