refactor mainclass