DW: Code refactor