code refactoring

moved main method content to another method.