Significant refactoring
refactored code