preventing error when typeElement is undefined