Added refactored code