added check for invalid typ