refactored and started testing