separate construction and destruction logic from main