Refactoring

divide main into controller