Partially refactored code