some refactoring, add login but it does not work