refactored CW with OOP