Improve a piece of code