Separated working for login and registration