implemented login, overall refactoring