.
refactored and tests