refactored to a more OO way of putting thigs