Fix an bug and add the login check