create new main class and some code corrections