Refactord code