more refactoring
major refactor done