Refactor for magento service