Update logic for login and main page