Checking for element and logging in