Abstract logic from main function into new class