Adding more logic for login functionality