Refactor as per requested