refactor code into objects for sanity