Added checking for namespace existence