move code from main class