refactored to use traits better