refactored
updated code