refactored Code