refactored structure to be more object oriented