refactoring to new model and functionality. so far semiworking