add namespaces , stats refactoring ( all my life I wanted to write a lambda function now finally)