Fix a bug in login, add more debug