fixed some bugs related to automatic log in