Add functions for login
Refactor