Refactor and move outside of namespace