first full refactored code ready to betatest