Refactor the code dynamically