Code refactoring and retouch