reorganized code. Moved to trait analysis