Refactor: move code to own module and class