restructure to be more object-oriented