refactoring main routine as class