added automatic relog if login fails