Light refactoring
Refactored data flow using more functional style