infinite loop bug

If a template selector passed to loadTemplate function and no element
found for that selector the script will go in an infinite loop so we
need to exit if there is no template element