Why did you replace the existing code with this? Did the existing code not work? There is a duplication of logic here as the same code exists in this new version as exists in `is_element_visible'.