PW: refactoring