Add logic to detect whether masonry element exists in DOM