refactord code