Refacored code structure