__main__ refactoring