build_namespace current working with explicit function
Improvements and error checking to build_namespace