Fix - check if element exists

Fix in while loop where element is null when a popup component has been removed.
Merge pull request #11 from roboncode/patch-1

Fix - check if element exists