Refactoring the icon code