refactoring...
refactored, adding more tests