refactor code a bit and allow namespaces