refactored and added more tests, more logic
refactored and added more tests, more logic