Adding logic to handle logging in