DW: Code refactoring