Add Main() and refactoring