fixed some bugs in login script