basic refactor
more refactoring