begun refactoring
transition fully working - lines to be included
completed refactoring