refactoring
Implemented login/registration logic