refactored code base working