Refractor writing code