refactored code
updated