refactor code to use namespaces