refactored to OOP; no testing yet