main.cs refactoring